# -*- coding: utf-8 -*-
''' 二值图像 '''
import cv2 as cv

img = cv.imread('../resources/miku.jpg')
h, w, c = img.shape

for y in range(h):
    for x in range(w):
        b, g, r = img[y, x]
        if int(b) + int(g) + int(r) >= 382.5:
            img[y, x] = [255, 255, 255]
        else:
            img[y, x] = [0, 0, 0]

# cv.imwrite('../resources/miku_binary.jpg', img)
cv.imshow('img', img)
cv.waitKey(0)
cv.destroyAllWindows()